package com.siyu.preplan.planpdtml.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.siyu.common.core.controller.BaseController;
import com.siyu.common.core.domain.AjaxResult;
import com.siyu.common.core.page.TableDataInfo;
import com.siyu.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.siyu.preplan.planpdtml.domain.PlanPDtml;
import com.siyu.preplan.planpdtml.service.IPlanPDtmlService;

/**
 * 仓库物资信息Controller
 *
 * @author hrhy
 * @date 2024-08-14
 */
@RestController
@RequestMapping("/planpdtml/PlanPDtml")
public class PlanPDtmlController extends BaseController
{
    @Autowired
    private IPlanPDtmlService planPDtmlService;

    /**
     * 查询仓库物资信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PlanPDtml planPDtml)
    {
        startPage();
        List<PlanPDtml> list = planPDtmlService.selectPlanPDtmlList(planPDtml);
        return getDataTable(list);
    }

    /**
     * 导出仓库物资信息列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, PlanPDtml planPDtml)
    {
        List<PlanPDtml> list = planPDtmlService.selectPlanPDtmlList(planPDtml);
        ExcelUtil<PlanPDtml> util = new ExcelUtil<PlanPDtml>(PlanPDtml.class);
        util.exportExcel(response, list, "仓库物资信息数据");
    }

    /**
     * 获取仓库物资信息详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(planPDtmlService.selectPlanPDtmlById(id));
    }

    /**
     * 新增仓库物资信息
     */
    @PostMapping
    public AjaxResult add(@RequestBody PlanPDtml planPDtml)
    {
        return toAjax(planPDtmlService.insertPlanPDtml(planPDtml));
    }

    /**
     * 修改仓库物资信息
     */
    @PutMapping
    public AjaxResult edit(@RequestBody PlanPDtml planPDtml)
    {
        return toAjax(planPDtmlService.updatePlanPDtml(planPDtml));
    }

    /**
     * 删除仓库物资信息
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(planPDtmlService.deletePlanPDtmlByIds(ids));
    }
}
